package com.netflexitysolutions.amazonws.ec2.internal.operations;

import com.amazonaws.ec2.doc._2009_04_04.ModifyImageAttributeType;
import com.amazonaws.ec2.doc._2009_04_04.ProductCodeItemType;
import com.amazonaws.ec2.doc._2009_04_04.ProductCodeListType;
import com.netflexitysolutions.amazonws.ec2.EC2;

public class SetProductCodeOperation extends SingleObjectOperationExecutor<ModifyImageAttributeType, Boolean> {

	private String productCode;
	
	public SetProductCodeOperation(EC2 ec2, String imageId, String productCode) {
		super(ec2, imageId);
		this.productCode = productCode;
	}

	@Override
	protected Boolean call(ModifyImageAttributeType request) {
		ProductCodeListType list = new ProductCodeListType();
		ProductCodeItemType item = new ProductCodeItemType();
		item.setProductCode(productCode);

		request.setProductCodes(list);
		list.getItem().add(item);
		
		return getEC2().getService().modifyImageAttribute(request).isReturn();
	}

}
